Rated
Viewed 9836 times
- Discuss (0 comments)
- Save as Favourite
- PDF Version
- Report Problem
Downloads
Related Categories
Treeview Reverse Sorting
you may have a treeview like this:
Main Node
+ The Parent
| - A
| - B
| - C
| - D
This routine will sort Z-A
so the result should be
Main Node
+ The Parent
| - D
| - C
| - B
| - A
Private Sub Command1_Click()
Dim tvn As Node
Dim tvn2 As Node
sName = 1 ' Change Node 1
' or sName = "MyNodeName"
Set tvn = TreeView1.Nodes(sName)
tvn.Sorted = True ' firstly sort A-Z then we simply replace last items with the first ones
tvn.Sorted = False
chil = tvn.Children: If chil = 0 Then Exit Sub ' if no children the exit
Set tvn = tvn.Child.LastSibling
For a = 1 To chil
Set tvn2 = tvn
Set tvn = tvn.Previous
TreeView1.Nodes.Remove tvn2.Index
TreeView1.Nodes.Add sName, 4, tvn2.Key, tvn2
Next
End Sub
Till the Roof comes off Till the Lights go out Till my Legs give out Can't shut my mouth I will not fall, my Wisdoms all.